package com.qf.smsplatform.monitor.config;

import com.qf.smsplatform.monitor.mq.GatewayFeeMessageJob;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.api.bootstrap.impl.ScheduleJobBootstrap;
import org.apache.shardingsphere.elasticjob.reg.base.CoordinatorRegistryCenter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: LeeRui
 * 2021/2/5 下午 9:20
 **/
@Configuration
public class MonitorFeeConfig {


    // 配置任务的执行周期
    @Bean
    public JobConfiguration jobFeeConfiguration() {
        JobConfiguration jobConfig = JobConfiguration.newBuilder("GatewayFeeMessageJob", 1).cron("0,30 * * * * ?").build();
        return jobConfig;
    }

    // 配置到ScheduleJobBootstrap
    @Bean
    public ScheduleJobBootstrap monitorFeeBootstrap(CoordinatorRegistryCenter coordinatorRegistryCenter,
                                                    GatewayFeeMessageJob gatewayFeeMessageJob,
                                                    JobConfiguration jobFeeConfiguration) {
        ScheduleJobBootstrap jobBootstrap = new ScheduleJobBootstrap(coordinatorRegistryCenter, gatewayFeeMessageJob, jobFeeConfiguration);
        jobBootstrap.schedule();
        return jobBootstrap;
    }


}
